<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header('道具列表')"></head>
<body class="gray-bg">
    
     <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="formId">
					<div class="select-list">
						<ul>
							<li>
								名称：<input type="text" name="name"/>
							</li>

							<li>
								稀有：
								<select id="rarely" name="rarely" style="width:80px;">
									<option value="">全部</option>
									<option value="0">否</option>
									<option value="1">是</option>
								</select>
							</li>

							<li>
								装备：
								<select id="equip" name="equip" style="width:80px;">
									<option value="">全部</option>
									<option value="0">否</option>
									<option value="1">是</option>
								</select>
							</li>

							<li>
								使用：
								<select id="usable" name="usable" style="width:80px;">
									<option value="">全部</option>
									<option value="0">否</option>
									<option value="1">是</option>
								</select>
							</li>

							<li>
								安装：
								<select id="placement" name="placement" style="width:80px;">
									<option value="">全部</option>
									<option value="0">否</option>
									<option value="1">是</option>
								</select>
							</li>

							<li>
								任务：
								<select id="task" name="task" style="width:80px;">
									<option value="">全部</option>
									<option value="0">否</option>
									<option value="1">是</option>
								</select>
							</li>

							<li>
								所属城市：
								<select id="belongsCity" name="belongsCity" style="width:150px;">
									<option value="">全部</option>
									<option th:each="city:${cities}"  th:value="${city.id}" th:text="${city.cityname}" value="1">
										aaa
									</option>
								</select>
							</li>

							<li>
								所属商店：
								<select id="belongsShop" name="belongsShop" style="width:150px;">
									<option value="">全部</option>
								</select>
							</li>

							<li>
								道具等级：<input type="text" name="itemLevel"/>
							</li>
							<li>
								备注信息：<input type="text" name="remark"/>
							</li>

							<li>
								状态：
								<select id="delFlag" name="delFlag" style="width:80px;">
									<option value="">全部</option>
									<option value="0">正常</option>
									<option value="1">禁用</option>
								</select>
							</li>

							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
	        <div class="btn-group-sm hidden-xs" id="toolbar" role="group">
				<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="fantasy:fantasyItemtype:add">
					<i class="fa fa-plus"></i> 添加
				</a>
				<a class="btn btn-primary btn-edit" onclick="$.operate.edit()" shiro:hasPermission="fantasy:fantasyItemtype:edit">
					<i class="fa fa-edit"></i> 修改
				</a>
				<a class="btn btn-warning btn-del btn-del" onclick="$.operate.disableAll()" shiro:hasPermission="fantasy:fantasyItemtype:disable">
					<i class="fa fa-minus"></i> 禁用
				</a>
				<a class="btn btn-warning btn-del btn-del" onclick="$.operate.restoreAll()" shiro:hasPermission="fantasy:fantasyItemtype:disable">
					<i class="fa fa-check"></i> 还原
				</a>
				<a class="btn btn-danger btn-del btn-del" onclick="$.operate.removeAll()" shiro:hasPermission="fantasy:fantasyItemtype:remove">
					<i class="fa fa-remove"></i> 删除
				</a>
			</div>
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('fantasy:fantasyItemtype:edit')}]];
        var removeFlag = [[${@permission.hasPermi('fantasy:fantasyItemtype:remove')}]];
        var disableFlag = [[${@permission.hasPermi('fantasy:fantasyItemtype:disable')}]];
        var prefix = ctx + "fantasy/fantasyItemtype";
		var itemType = [[${@dict.getType('item_type')}]];

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                disableUrl: prefix + "/disable",
                restoreUrl: prefix + "/restore",
				exportUrl: prefix + "/export",
                modalName: "道具类型",
				search: false,
		        showExport: true,
                columns: [{
		            checkbox: true
		        },
				{
					field : 'id', 
					title : '序号',
					visible: false
				},
				{
					field : 'name', 
					title : '名称',
					sortable: true
				},
				{
					field : 'itemType',
					title : '道具类型',
					sortable: true,
					formatter: function(value, row, index) {
						return $.table.selectDictLabel(itemType, value);
					}
				},
				{
					field : 'durability',
					title : '耐久',
					sortable: true
				},
				{
					field : 'coolingTime',
					title : '冷却时间',
					sortable: true
				},
				{
					field : 'capacity',
					title : '容量',
					sortable: true
				},
				{
					field : 'title',
					title : '称号',
					sortable: true
				},
				{
					field : 'mastery',
					title : '最低熟练度',
					sortable: true
				},
				{
					field : 'material',
					title : '材料',
					sortable: false
				},
				{
					field : 'rarelyStr',
					title : '稀有',
					sortable: true
				},
				{
					field : 'imgsrc', 
					title : '道具图片',
					sortable: true,
                    formatter: showImg,
                    events: 'operateEvents'
				},
				{
					field : 'groundStr',
					title : '初始化',
					sortable: true
				},
				{
					field : 'equipStr',
					title : '装备',
					sortable: true
				},
				{
					field : 'usableStr',
					title : '使用',
					sortable: true
				},
				{
					field : 'placementStr',
					title : '安装',
					sortable: true
				},
				{
					field : 'taskStr',
					title : '任务',
					sortable: true
				},
				{
					field : 'cityname',
					title : '所属城市',
					sortable: true
				},
				{
					field : 'belongsShop', 
					title : '所属商店',
					sortable: true
				},
				{
					field : 'itemLevel', 
					title : '道具等级',
					sortable: true
				},
				{
					field : 'scope',
					title : '影响范围',
					sortable: true
				},
				{
					field : 'property',
					title : '影响属性',
					sortable: true
				},
				{
					field : 'propertyVal',
					title : '属性变动值',
					sortable: true
				},
				{
					field : 'updateBy',
					title : '更新者',
					sortable: true
				},
				{
					field : 'updateTime', 
					title : '更新时间',
					sortable: true
				},
				{
					field : 'remark', 
					title : '备注信息',
					sortable: true
				},
				{
					field : 'delFlag', 
					title : '状态',
					sortable: true
				},
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
		            	actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        actions.push('<a class="btn btn-warning btn-xs ' + disableFlag + '" href="#" onclick="$.operate.disable(\'' + row.id + '\')"><i class="fa fa-minus"></i>禁用</a> ');
                        actions.push('<a class="btn btn-warning btn-xs ' + disableFlag + '" href="#" onclick="$.operate.restore(\'' + row.id + '\')"><i class="fa fa-check"></i>还原</a> ');
						return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
        });

        function showImg(value, row, index) {
            var imgSrc = ctx + 'profile/' + value;
            var s = '<a class = "view"  href="javascript:void(0)"><img style="width:30px;height:30px;"  src="'+imgSrc+'" /></a>';
            return s;
        }

        window.operateEvents = {
            'click .view': function (e, value, row, index) {
                var imgSrc = ctx + 'profile/' + value;
                layer.open({
                    type: 1,
                    title: false,
                    closeBtn: 0,
                    area: 'auto',
                    skin: 'layui-layer-nobg', //没有背景色
                    shadeClose: true,
                    content: '<img src="'+imgSrc+'"/>'
                });
            },
        };
    </script>
</body>
</html>